let graphicLayer;

export default {
	init(map) {
		graphicLayer = new mars3d.layer.GraphicLayer({
			name: "矢量数据图层"
		});
		
		// 图层统一绑定popup
		graphicLayer.bindPopup(function(event) {
			const attr = event.graphic.attr || {}
			attr["类型"] = event.graphic.type
			attr["来源"] = "我是layer上绑定的Popup"
			attr["备注"] = "我支持鼠标交互"
		
			return mars3d.Util.getTemplateHtml({
				title: "矢量图层",
				template: "all",
				attr: attr
			})
		})
		
		map.addLayer(graphicLayer);
	},
	add(entity) {
		graphicLayer.addGraphic(entity);
	},
	clear() {
		graphicLayer.clear();
	}
}